<?php
namespace app\index\controller\traits;

use think\Debug;

trait CurlRequest
{
    
    //protected $model;

    public function updateToRecent()
    {
        
        $this->model->updateToRecent();

    }

    /**
     * 清空表复位主键序号
     *
     * @return   void
     */
    public function clearTbl()
    {

        $this->model->clearTbl();
        $rtn['success'] = true;

        _callback($rtn);
    }
    /**
     * 清空表复位主键序号,获取全量最新记录
     *
     * @return   void
     */
    public function resetTbl()
    {

        ini_set('memory_limit', '32M');

        $this->model->clearTbl();

        Debug::remark('begin');

        $rtn['success'] = true;
        $rtn['msg']     = $this->model->getAllRecords();

        //计算持续时间并保存
        Debug::remark('end');

        $data['last_time'] = Debug::getRangeTime('begin', 'end');
        $data['mem_peak']  = Debug::getMemPeak('begin', 'end');
        $data['mem_range'] = Debug::getRangeMem('begin', 'end');
        $data['mem_use']   = Debug::getUseMem();

        $rtn['data'] = $data;

        _callback($rtn);
    }
}
